const { getQuestionnaire, saveQuestionnaire } = require('../services/questionnaire')
const { SuccessModel, ErrorModel } = require('../model/ModelInfo')
const { getQuestnaireError, saveQuestnaireError } = require('../model/ErrorInfo')

module.exports = {
  async saveQuestionnaire ({type, group, unit, answers, questuser}) {
    const result = await saveQuestionnaire({type, group, unit, answers, questuser})
    if (!result) {
      return new ErrorModel(saveQuestnaireError)
    }
    return new SuccessModel(result)
  },
  async getQuestionnaire ({type, group, unit}) {
    const result = await getQuestionnaire({type, group, unit})
    if (!result) {
      return new ErrorModel(getQuestnaireError)
    }
    return new SuccessModel(result)
  }
}
